package com.example.demo.service.impl;

import com.example.demo.entity.User;
import com.example.demo.mapper.UserMapper;
import com.example.demo.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Resource
    private UserMapper userMapper;

    @Override
    public int insert(User user) {
        return userMapper.insert(user);
    }

    @Override
    public int updateById(User user) {
        return userMapper.updateById(user);
    }

    @Override
    public int updatePassword(Integer id, String password) {
        return userMapper.updatePassword(id, password);
    }

    @Override
    public int deleteById(Long id) {
        return userMapper.deleteById(id);
    }

    @Override
    public int deleteBatchIds(List<Integer> ids) {
        return userMapper.deleteBatchIds(ids);
    }

    @Override
    public User selectByUsernameAndPassword(String username, String password) {
        return userMapper.selectByUsernameAndPassword(username, password);
    }

    @Override
    public User selectByUsername(String username) {
        return userMapper.selectByUsername(username);
    }

    @Override
    public List<User> selectPage(int pageNum, int pageSize, String search) {
        int offset = (pageNum - 1) * pageSize;
        return userMapper.selectPage(offset, pageSize, search);
    }

    @Override
    public List<User> selectPageWithMultiSearch(int pageNum, int pageSize, String search1, String search2, String search3, String search4) {
        int offset = (pageNum - 1) * pageSize;
        return userMapper.selectPageWithMultiSearch(offset, pageSize, search1, search2, search3, search4);
    }

    @Override
    public int selectCount(String search) {
        return userMapper.selectCount(search);
    }

    @Override
    public int selectCountWithMultiSearch(String search1, String search2, String search3, String search4) {
        return userMapper.selectCountWithMultiSearch(search1, search2, search3, search4);
    }
}
